function orderService($http) {

    var urlBase = "/api/order";

    var svc = this;

    function getAllUntreatedOrder(){
        return $http.get(urlBase+"/getOrderWithStateByMerchantId/0");
    }


    function getAllReceiveOrder(){
        return $http.get(urlBase+"/getOrderWithStateByMerchantId/1");
    }

    function getAllDeliveryOrder(){
        return $http.get(urlBase+"/getOrderWithStateByMerchantId/3");
    }


    function getAllFinishOrder(){
        return $http.get(urlBase+"/getOrderWithStateByMerchantId/4");
    }


    function getAllRefuseOrder(){
        return $http.get(urlBase+"/getOrderWithStateByMerchantId/2");
    }


    function updateRefuseOrder(orderId){
        return $http.post(urlBase+"/updateOrderStateByOrderId/2/"+orderId);
    }

    function updateReceiveOrder(orderId){
        return $http.post(urlBase+"/updateOrderStateByOrderId/1/"+orderId);
    }

    function updateDeliveryOrder(orderId){
        return $http.post(urlBase+"/updateOrderStateByOrderId/3/"+orderId);
    }


    return {
        getAllUntreatedOrder: getAllUntreatedOrder,
        getAllReceiveOrder : getAllReceiveOrder,
        getAllDeliveryOrder : getAllDeliveryOrder,
        getAllFinishOrder:getAllFinishOrder,
        getAllRefuseOrder:getAllRefuseOrder,
        updateRefuseOrder:updateRefuseOrder,
        updateReceiveOrder:updateReceiveOrder,
        updateDeliveryOrder:updateDeliveryOrder
    }
}

module.exports = orderService;
